


//
//  JJSnowViewController.m
//  MyAnimations
//
//  Created by jxf on 15/12/23.
//  Copyright © 2015年 JJ.sevn. All rights reserved.
//

#import "JJSnowViewController.h"
#import "JJPublicMacro.h"

@interface JJSnowViewController ()

@end
@implementation JJSnowViewController


- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setupEmi];
}

- (void)setupEmi
{
    CAEmitterLayer *emitterLayer = [CAEmitterLayer layer];
    [self.view.layer addSublayer:emitterLayer];
    // 属性
    emitterLayer.emitterShape = kCAEmitterLayerLine;
    emitterLayer.emitterMode = kCAEmitterLayerBackToFront;
    emitterLayer.emitterSize = CGSizeMake(ScreenW * 2, 44);
    emitterLayer.anchorPoint = CGPointMake(0, 0);
    emitterLayer.position = CGPointMake(0, 0);
    
    CAEmitterCell *flake = [CAEmitterCell emitterCell];
    flake.contents = (id)[UIImage imageNamed:@"flake1"].CGImage;
    CAEmitterCell *flake1 = [CAEmitterCell emitterCell];
    flake1.contents = (id)[UIImage imageNamed:@"flake1"].CGImage;
    // 配置属性
    flake.lifetime = 100;
    flake.birthRate = 100;
    flake1.lifetime = 5;
    flake1.birthRate = 5;
    // 初始速度
    flake.velocity = 5;
    flake.velocity = 5;
    flake.velocityRange = 5;
    flake.velocityRange = 5;
    // y方向加速度
    flake.yAcceleration = 1;
    flake.scaleRange = 1.0;
    flake.alphaRange = 1.0;
    flake1.yAcceleration = 1;
    flake1.scaleRange = 1.0;
    flake1.alphaRange = 1.0;
    // 旋转角度
    flake.spinRange = M_PI * 0.1;
    flake1.spinRange = M_PI * 0.1;
    // 发射角度
    flake.emissionLongitude = M_PI_2;
    flake.emissionRange = M_PI_2;
    flake1.emissionLongitude = M_PI_2;
    flake1.emissionRange = M_PI_2;
//    flake.color = [UIColor lightGrayColor].CGColor;
    
    emitterLayer.shadowOpacity = 1.0;
    emitterLayer.shadowRadius = 0.0;
    emitterLayer.shadowOffset = CGSizeMake(0.0, 1.0);
    emitterLayer.shadowColor = [[UIColor whiteColor] CGColor];

    
    emitterLayer.emitterCells = @[flake, flake1];
}

#pragma mark -
#pragma mark - backHome
- (IBAction)backHome:(UIBarButtonItem *)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (BOOL)prefersStatusBarHidden
{
    return YES;
}
@end
